package com.aop.proxy.jdk;

import java.lang.reflect.Proxy;

public class Main {
    public static void main(String[] args) {
        DayWorkImpl dayWork = new DayWorkImpl();
        TimeHandler handler = new TimeHandler(dayWork); //传入目标方法
        IDayWork iDayWork = (IDayWork) Proxy.newProxyInstance(dayWork.getClass().getClassLoader(),
                dayWork.getClass().getInterfaces(),
                handler);  //这三个参数分别是：目标的ClassLoader对象、提供给目标类的接口对象、InvocationHandler 对象。
        iDayWork.breakfast();
        iDayWork.lunch();
        iDayWork.dinner();
        System.out.println(iDayWork.getClass()); //class com.sun.proxy.$Proxy0
    }
}
